tools/*/build/lib*/*.py
tools/balloon/balloon
tools/check/.*
+tools/libxc/xen
tools/misc/miniterm/miniterm
tools/misc/xen_cpuperf
tools/web-shutdown.tap
XEN_ROOT = ../..
include $(XEN_ROOT)/tools/Make.defs
-vpath %.h $(XEN_HYPERVISOR_IFS)
-INCLUDES += -I $(XEN_HYPERVISOR_IFS)
-
vpath %h $(XEN_LINUX_INCLUDE)
INCLUDES += -I $(XEN_LINUX_INCLUDE)
LIB = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)
-all: check-for-zlib $(LIB)
+all: check-for-zlib mk-symlinks $(LIB)
check-for-zlib:
@if [ ! -e /usr/include/zlib.h ]; then \
false; \
fi
+mk-symlinks:
+ ln -sf $(XEN_HYPERVISOR_IFS) xen
+
install: all
mkdir -p $(prefix)/usr/lib
mkdir -p $(prefix)/usr/include
install -m0644 xc.h $(prefix)/usr/include
clean:
- $(RM) *.a *.so *.o *.rpm $(LIB)
- $(RM) *~
- $(RM) $(DEPS)
+ $(RM) *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen
rpm: all
rm -rf staging
*
* A library for low-level access to the Xen control interfaces.
*
- * Copyright (c) 2003, K A Fraser.
+ * Copyright (c) 2003-2004, K A Fraser.
*/
#ifndef __XC_H__
typedef signed long s32;
typedef signed long long s64;
+#include "xen/hypervisor-if.h"
+#include "xen/dom0_ops.h"
+#include "xen/event_channel.h"
+#include "xen/sched_ctl.h"
+#include "xen/io/domain_controller.h"
+
/* Obtain or relinquish a handle on the 'xc' library. */
int xc_interface_open(void);
int xc_interface_close(int xc_handle);
unsigned long max_memkb;
} xc_dominfo_t;
-typedef struct xc_shadow_control_stats_st
-{
- unsigned long fault_count;
- unsigned long dirty_count;
- unsigned long dirty_net_count;
- unsigned long dirty_block_count;
-} xc_shadow_control_stats_t;
-
+typedef dom0_getdomaininfo_t xc_domaininfo_t;
int xc_domain_create(int xc_handle,
unsigned int mem_kb,
int cpu,
u32 first_domid,
unsigned int max_doms,
xc_dominfo_t *info);
+int xc_domain_getfullinfo(int xc_handle,
+ u32 domid,
+ xc_domaininfo_t *info,
+ full_execution_context_t *ctxt);
int xc_domain_setcpuweight(int xc_handle,
u32 domid,
float weight);
+long long xc_domain_get_cpu_usage(int xc_handle,
+ domid_t domid);
+
+typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
int xc_shadow_control(int xc_handle,
u32 domid,
unsigned int sop,
int xc_rrobin_global_get(int xc_handle, u64 *slice);
-#define DOMID_SELF (0x7FF0U)
-#define DOMID_IO (0x7FF1U)
-#define DOMID_XEN (0x7FF2U)
-
-typedef struct {
-#define EVTCHNSTAT_closed 0 /* Chennel is not in use. */
-#define EVTCHNSTAT_unbound 1 /* Channel is not bound to a source. */
-#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
-#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
-#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
- int status;
- union {
- struct {
- u32 dom;
- int port;
- } interdomain;
- int pirq;
- int virq;
- } u;
-} xc_evtchn_status_t;
-
+typedef evtchn_status_t xc_evtchn_status_t;
int xc_evtchn_alloc_unbound(int xc_handle,
u32 dom,
int *port);
unsigned int max_chars,
int clear);
-typedef struct {
- int ht_per_core;
- int cores;
- unsigned long total_pages;
- unsigned long free_pages;
- unsigned long cpu_khz;
-} xc_physinfo_t;
-
+typedef dom0_physinfo_t xc_physinfo_t;
int xc_physinfo(int xc_handle,
xc_physinfo_t *info);
int xc_domain_getfullinfo(int xc_handle,
u32 domid,
- dom0_op_t *op,
- full_execution_context_t *ctxt )
+ xc_domaininfo_t *info,
+ full_execution_context_t *ctxt)
{
int rc;
- op->cmd = DOM0_GETDOMAININFO;
- op->u.getdomaininfo.domain = (domid_t)domid;
- op->u.getdomaininfo.ctxt = ctxt;
+ dom0_op_t op;
+
+ op.cmd = DOM0_GETDOMAININFO;
+ op.u.getdomaininfo.domain = (domid_t)domid;
+ op.u.getdomaininfo.ctxt = ctxt;
+
+ rc = do_dom0_op(xc_handle, &op);
+
+ memcpy(info, &op.u.getdomaininfo, sizeof(*info));
- rc = do_dom0_op(xc_handle, op);
- if ( ((u16)op->u.getdomaininfo.domain != domid) && rc > 0 )
+ if ( ((u16)op.u.getdomaininfo.domain != domid) && rc > 0 )
return -ESRCH;
else
return rc;
op.u.status.port = port;
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
- {
- switch ( status->status = op.u.status.status )
- {
- case EVTCHNSTAT_interdomain:
- status->u.interdomain.dom = (u16)op.u.status.u.interdomain.dom;
- status->u.interdomain.port = op.u.status.u.interdomain.port;
- break;
- case EVTCHNSTAT_pirq:
- status->u.pirq = op.u.status.u.pirq;
- break;
- case EVTCHNSTAT_virq:
- status->u.virq = op.u.status.u.virq;
- break;
- }
- }
+ memcpy(status, &op.u.status, sizeof(*status));
return rc;
}
}
-int suspend_and_state( int xc_handle, XcIOContext *ioctxt,
- dom0_op_t *op,
- full_execution_context_t *ctxt )
+int suspend_and_state(int xc_handle, XcIOContext *ioctxt,
+ xc_domaininfo_t *info,
+ full_execution_context_t *ctxt)
{
int i=0;
retry:
- if ( xc_domain_getfullinfo( xc_handle, ioctxt->domain, op, ctxt) )
+ if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, info, ctxt) )
{
xcio_error(ioctxt, "Could not get full domain info");
return -1;
}
- if ( (op->u.getdomaininfo.flags &
- ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
- == ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
+ if ( (info->flags &
+ (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT))) ==
+ (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT)) )
{
return 0; // success
}
- if ( op->u.getdomaininfo.flags & DOMFLAGS_PAUSED )
+ if ( info->flags & DOMFLAGS_PAUSED )
{
// try unpausing domain, wait, and retest
xc_domain_unpause( xc_handle, ioctxt->domain );
xcio_error(ioctxt, "Domain was paused. Wait and re-test. (%lx)",
- op->u.getdomaininfo.flags);
+ info->flags);
usleep(10000); // 10ms
goto retry;
if( ++i < 100 )
{
xcio_error(ioctxt, "Retry suspend domain (%lx)",
- op->u.getdomaininfo.flags);
+ info->flags);
usleep(10000); // 10ms
goto retry;
}
xcio_error(ioctxt, "Unable to suspend domain. (%lx)",
- op->u.getdomaininfo.flags);
+ info->flags);
return -1;
}
int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
{
- dom0_op_t op;
+ xc_domaininfo_t info;
+
int rc = 1, i, j, k, last_iter, iter = 0;
unsigned long mfn;
u32 domid = ioctxt->domain;
return 1;
}
- if ( xc_domain_getfullinfo( xc_handle, domid, &op, &ctxt) )
+ if ( xc_domain_getfullinfo( xc_handle, domid, &info, &ctxt) )
{
xcio_error(ioctxt, "Could not get full domain info");
goto out;
}
- shared_info_frame = op.u.getdomaininfo.shared_info_frame;
+ shared_info_frame = info.shared_info_frame;
/* A cheesy test to see whether the domain contains valid state. */
if ( ctxt.pt_base == 0 ){
goto out;
}
- nr_pfns = op.u.getdomaininfo.max_pages;
+ nr_pfns = info.max_pages;
/* cheesy sanity check */
if ( nr_pfns > 1024*1024 ){
last_iter = 1;
- if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
+ if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
{
xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
- op.u.getdomaininfo.flags);
+ info.flags);
goto out;
}
DPRINTF("Start last iteration\n");
last_iter = 1;
- if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
+ if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
{
xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
- op.u.getdomaininfo.flags);
+ info.flags);
goto out;
}
xcio_info(ioctxt,
"SUSPEND flags %08lx shinfo %08lx eip %08lx "
- "esi %08lx\n", op.u.getdomaininfo.flags,
- op.u.getdomaininfo.shared_info_frame,
+ "esi %08lx\n",info.flags,
+ info.shared_info_frame,
ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
}
{
int ret;
dom0_op_t op;
- dom0_physinfo_t *got_info = &op.u.physinfo;
op.cmd = DOM0_PHYSINFO;
op.interface_version = DOM0_INTERFACE_VERSION;
- if((ret = do_dom0_op(xc_handle, &op))) return ret;
+ if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
+ return ret;
- put_info->ht_per_core = got_info->ht_per_core;
- put_info->cores = got_info->cores;
- put_info->total_pages = got_info->total_pages;
- put_info->free_pages = got_info->free_pages;
- put_info->cpu_khz = got_info->cpu_khz;
+ memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
return 0;
}
#include "xc.h"
-/* from xen/include/hypervisor-ifs */
-#include <hypervisor-if.h>
-#include <dom0_ops.h>
-#include <event_channel.h>
-#include <sched_ctl.h>
-#include <io/domain_controller.h>
-
#include <asm-xen/proc_cmd.h>
} mfn_mapper_t;
-long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid );
-
#include "xc_io.h"
-int xc_domain_getfullinfo(int xc_handle,
- u32 domid,
- dom0_op_t *op,
- full_execution_context_t *ctxt );
-
unsigned long xc_get_m2p_start_mfn ( int xc_handle );
#endif /* __XC_PRIVATE_H__ */
CC = gcc
CFLAGS = -Wall -O3
-INCLUDES += -I $(XEN_HYPERVISOR_IFS)
INCLUDES += -I $(XEN_LINUX_INCLUDE)
INCLUDES += -I $(XEN_XC)
INCLUDES += -I $(XEN_LIBXC)
CC = gcc
CFLAGS = -Wall -Werror -O3
-CFLAGS += -I $(XEN_HYPERVISOR_IFS)
CFLAGS += -I $(XEN_LINUX_INCLUDE)
CFLAGS += -I $(XEN_XC)
CFLAGS += -I $(XEN_LIBXC)
#include <signal.h>
#include "xc_private.h"
-
-/* from xen/include/hypervisor-ifs */
-#include <trace.h>
+#include <xen/trace.h>
extern FILE *stderr;
XFRD_INSTALL_DIR = /usr/sbin
-vpath %.h $(XEN_HYPERVISOR_IFS)
-INCLUDES += -I $(XEN_HYPERVISOR_IFS)
-
vpath %h $(XEN_LINUX_INCLUDE)
INCLUDES += -I $(XEN_LINUX_INCLUDE)
mkdir -p $(prefix)/boot
install -m0644 $(TARGET).gz $(prefix)/boot
install -m0644 $(TARGET)-syms $(prefix)/boot
+ mkdir -p $(prefix)/usr/include/xen/io
+ install -m0644 include/hypervisor-ifs/*.h $(prefix)/usr/include/xen
+ install -m0644 include/hypervisor-ifs/io/*.h $(prefix)/usr/include/xen/io
+ install -m0644 include/hypervisor-ifs/COPYING $(prefix)/usr/include/xen
dist: $(TARGET)
$(MAKE) prefix=`pwd`/../install dist=yes install